home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-07-17 | 74.5 KB | 2,500 lines |
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // ----------------------------------------------------------------------------
- // Utility procedures used by other procedures in this file
- //
-
- // Keep track of the height/width ratio.
- global float $deviceAspect = 0;
-
- proc setParentToCommonTab()
- {
- setParent `rendererTabLayoutName("mayaHardware")`;
- setParent commonTabColumn;
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the file name preview area
- //
-
- proc createTargetFilePreview()
- {
- string $oldParent = `setParent -query`;
-
- columnLayout
- -adjustableColumn true
- mayaHardwareTargetFilePreview;
-
- text
- -align "left"
- -font "boldLabelFont"
- -label "Path"
- exampleText0;
- text
- -align "left"
- -font "boldLabelFont"
- -label "File Name"
- exampleText1;
- text
- -align "left"
- -font "boldLabelFont"
- -label "To"
- exampleText2;
-
- setParent $oldParent;
-
- // This target file preview is affected by a number of attributes.
- // If any of those attributes change, this preview needs to be updated.
- //
- // Here we fill an array with the names of all of the current renderer's
- // attributes which affect the naming of the target file.
- //
- string $attrArray[];
-
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.filename";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.imageFormat";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.byFrame";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.startFrame";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.endFrame";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.modifyExtension";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.startExtension";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.byExtension";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.useCustomExtension";
- $attrArray[size($attrArray)] = "hardwareRenderGlobals.customExtension";
-
- // Now we establish scriptJobs to invoke the procedure which updates the
- // target file preview when any of the above attributes change.
- //
- int $i;
-
- for ($i = 0; $i < size($attrArray); $i++)
- {
- scriptJob
- -attributeChange
- $attrArray[$i]
- "updateMayaHardwareTargetFilePreview"
- -parent mayaHardwareTargetFilePreview;
- }
-
- scriptJob
- -parent mayaHardwareTargetFilePreview
- -event
- workspaceChanged
- "updateMayaHardwareTargetFilePreview";
- }
-
- global proc updateMayaHardwareTargetFilePreview()
- {
- //
- // Description:
- // This procedure is called any time an attribute change occurs which
- // would affect the name(s) of the file(s) that would be created when the
- // user performs a render.
- // This procedure updates the lines of text in the General tab that allow
- // the user to see what files are going to be created when they render.
- //
-
- string $oldParent = `setParent -query`;
-
- string $renderer = "mayaHardware";
- string $tabLayout = rendererTabLayoutName($renderer);
- setParent $tabLayout;
-
- //
- // Update the Path portion of the preview.
- //
-
- // get the project's image directory
- //
- string $imgDir = `workspace -q -rte "images"`;
- string $fullPath = `workspace -expandName $imgDir`;
-
- $path = " Path: "+ $fullPath + "/";
-
- text -edit -label $path exampleText0;
-
- //
- // Update the File Name portion of the preview.
- //
-
- string $title1 = " File Name: ";
- string $title2 = " To: ";
-
- string $filename = `getAttr hardwareRenderGlobals.filename`;
- string $prefix;
-
- // Image extension
- string $imageType="";
-
- if (`getAttr "hardwareRenderGlobals.useCustomExtension"`)
- {
- // User specified
- $imageType = "."+`getAttr "hardwareRenderGlobals.customExtension"` ;
- }
- else
- {
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
- int $imageNum = `getAttr "hardwareRenderGlobals.imageFormat"`;
- int $i;
- for ($i=0; $i < size($imgExtNum); ++$i)
- {
- if ($imageNum == $imgExtNum[$i])
- {
- $imageType = "."+$imgExt[$i];
- break;
- }
- }
- }
- // int $imageUse = 0;
-
- // Frames number extension
- float $startFrame = `getAttr "hardwareRenderGlobals.startFrame"`;
- float $endFrame = `getAttr "hardwareRenderGlobals.endFrame"`;
-
- // if ($useAnim)
- // {
- // // if useAnim, make sure it's not a movie format, or else
- // // bad extension names will be printed out to the window.
- // int $imgFormat = `getAttr "hardwareRenderGlobals.imageFormat"`;
- // if ($imgFormat == 21 || $imgFormat == 22 || $imgFormat == 23)
- // $useAnim = 0;
- // }
- // if ($useAnim)
- // {
- float $byf = `getAttr hardwareRenderGlobals.byFrame`;
- if ($byf == 0.0) $byf = 0.00001;
-
- int $pad = `intFieldGrp -query -value1 framePaddingCtrl`;
-
- // Check if the padding is a valid number. A valid
- // padding is >= 0.
- //
- if ($pad < 0)
- {
- intFieldGrp -edit -value1 0 framePaddingCtrl;
- $pad = 0;
- }
-
- int $f1 = `getAttr "hardwareRenderGlobals.startFrame"`;
- int $f2 = `getAttr "hardwareRenderGlobals.endFrame"`;
- int $numFrames = ($f2 - $f1) / $byf;
-
- // Check to see if the numbers are being modified
- if (`getAttr "hardwareRenderGlobals.modifyExtension"`)
- {
- $f1 = `getAttr hardwareRenderGlobals.startExtension`;
- $f2 = $f1
- + ($numFrames * `getAttr hardwareRenderGlobals.byExtension`);
- }
-
- // Check for fields
-
- // string $fieldExt = "";
- // int $whichFields = `getAttr hardwareRenderGlobals.fields`;
- // int $useFields = ($whichFields != 0);
- // int $useFieldExt = (`getAttr "hardwareRenderGlobals.fieldExtControl"` != 1);
- // int $defFieldExt = (`getAttr "hardwareRenderGlobals.fieldExtControl"` == 0);
-
- // Construct the file names
- //
- int $useAnim = `getAttr "defaultRenderGlobals.animation"`;
- string $filename1;
-
- // If we are using a animation format, then we don't need frame
- // number in the file name.
- //
- if (checkMayaHardwareMultiframeFormat())
- {
- $useAnim = false;
- }
-
- if ($useAnim)
- {
- $filename1 = `hwRender -imageFileName -frame $f1`;
- }
- else
- {
- $filename1 = `hwRender -imageFileName `;
- }
-
-
- // Set the example file text control.
- //
- text
- -edit
- -label ($title1+$filename1)
- exampleText1;
-
- if ($useAnim)
- {
- string $filename2 = `hwRender -imageFileName -frame $f2`;
- text
- -edit
- -label ($title2+$filename2)
- exampleText2;
- }
- else
- {
- text -edit -label "" exampleText2;
- }
-
- setParent $oldParent;
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the Image File Output frame
- //
-
- proc createFileNamePrefixControl()
- {
- // Create the control
- //
- textFieldGrp
- -label "File Name Prefix"
- -changeCommand ("changeMayaHardwareFileNamePrefix")
- mayaHardwareFilePrefix;
-
- // Create a scriptJob which will update the control when the value of the
- // attribute it represents is changed.
- //
- scriptJob
- -parent mayaHardwareFilePrefix
- -attributeChange
- "hardwareRenderGlobals.filename"
- "updateMayaHardwareFilenameRelatedControls";
-
- scriptJob
- -parent mayaHardwareFilePrefix
- -attributeChange
- "defaultRenderGlobals.animation"
- "updateMayaHardwareFilenameRelatedControls";
- }
-
- // Description: This procedure is called when we want to refresh the content
- // in the file name prefix control.
- //
- proc updateMayaHardwareFileNamePrefixControl(string $prefix)
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- if ($prefix == "%s")
- {
- $prefix = "(not set; using filename)";
- }
-
- // Update the "File Name Prefix" and the "File/Animation Ext" controls.
- //
- textFieldGrp -edit -text $prefix mayaHardwareFilePrefix;
-
- setParent $oldParent;
- }
-
- // Description: This procedure is called to extract the frame padding
- // string from the filename.
- //
- // The way HWRenderMaya\Render\TimageName.cpp works is that it takes
- // the last frame number specification as
- // the "official" frame number pattern.
- //
- // Example 1:
- // filename = "myFile%5n_separator_%3n_ending"
- // will give filenames like
- // myFile%5n_separator_001_ending
- // myFile%5n_separator_002_ending
- //
- // Example 2:
- // filename = "myFile%3n_separator_%3n_ending"
- // will give filenames like
- // myFile001_separator_001_ending
- // myFile001_separator_002_ending
- //
- proc string extractFramePaddingString(string $filename)
- {
- int $lengthFilename = size($filename);
-
- // If there is no frame number pattern, then we return the empty string.
- //
- if (`match "%[-._][0-9]*n" $filename` == "" &&
- `match "%[0-9]*n" $filename` == "" )
- {
- return "";
- }
-
- // Check substring ending to find the last frame number pattern.
- //
- int $lengthSubstring = $lengthFilename;
- while ($lengthSubstring >= 2 && $lengthSubstring <= $lengthFilename)
- {
- // Check the substring filename[1..i].
- // If the end of this substring is a frame number specification,
- // then extract the frame padding from it.
- //
- string $myString = `substring $filename 1 $lengthSubstring`;
- string $paddingString = `match "%[-._][0-9]*n$" $myString`;
- if ($paddingString != "")
- {
- return $paddingString;
- }
-
- $paddingString = `match "%[0-9]*n$" $myString`;
- if ($paddingString != "")
- {
- return $paddingString;
- }
-
- // If we don't have a frame number pattern at the end of the
- // substring, we chop a character from the end of the substring
- // and search again.
- //
- $lengthSubstring = $lengthSubstring -1;
- }
- }
-
- // Description: This procedure is called to extract the frame padding
- // number out of the given filename.
- //
- proc int extractFramePadding(string $filename)
- {
- string $paddingString = extractFramePaddingString($filename);
-
- // If there is no frame padding pattern in the filename, we return -1.
- //
- if ($paddingString == "")
- {
- return -1;
- }
-
- $paddingString = `match "[0-9]*n$" $paddingString`;
- $paddingString = `match "[0-9]*" $paddingString`;
- int $padding;
- if ($paddingString == "")
- {
- // It must be the cases %n or %[-._]n, where frame padding is 1.
- //
- $padding = 1;
- }
- else
- {
- $padding = $paddingString;
- }
-
- if ($padding == 0)
- {
- $padding = 1;
- }
- return $padding;
- }
-
- // Description: This procedure is called when the image format is changed
- // to an animation format. We need to
- // . extact the filen prefix,
- // . update the Frame/Animation Ext accordingly,
- // . disable controls which are not useful for the animation format.
- //
- proc updateMayaHardwareMultiFrameControls()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- // Fix filename pattern to make sure the output filenames are unique.
- // In this procedure we deal with the case where the image format
- // is an animation format. After fixFileNameNumberPattern,
- // the new version of the $hwFileName has its frame number
- // pattern removed.
- //
- string $hwFilename = `hwRender -query -fixFileNameNumberPattern`;
-
- int $anim = `getAttr defaultRenderGlobals.animation`;
- int $item = 1;
- string $ending = "";
-
- // Extract the .ext ending of a filename if there is any.
- //
- if (`match "[.]%e$" $hwFilename` != "")
- {
- $ending = "[.]%e$";
- }
- else if (`match "%[.]e$" $hwFilename` != "")
- {
- $ending = "%[.]e$";
- }
-
- // Extract the prefix.
- //
- string $prefix = `substitute $ending $hwFilename ""`;
- updateMayaHardwareFileNamePrefixControl($prefix);
-
-
- // Set the "Frame/Animation Ext" to the appropriate menuItem.
- //
- if ($ending != "")
- {
- // There is an extension.
- //
- if ($anim)
- {
- // name.ext (Multi Frame)
- //
- $item = 8;
- }
- else
- {
- // name.ext (Single Frame)
- //
- $item = 2;
- }
- }
- else
- {
- // No extension.
- //
- if ($anim)
- {
- // name (Multi Frame)
- //
- $item = 7;
- }
- else
- {
- // name (Single Frame)
- //
- $item = 1;
- }
- }
- optionMenuGrp -edit -select $item mayaHardwareExtMenu;
-
- setParent $oldParent;
- }
-
- // Description: This procedure is called when a image file format is used
- // and we want to choose the appropriate Frame/Animation Ext and
- // set image filename related controls accordingly.
- //
- proc updateMayaHardwareNonMultiFrameControls()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- // If the format is a non-animation format, update related controls.
- //
- string $originalHwFilename = `getAttr "hardwareRenderGlobals.filename"`;
- int $animation = mayaHardwareGetCommonGlobalValue("animation");
- int $padding;
-
- // If we are in animation mode and the filename does not have a
- // frame number specification, then add a frame number specification
- // to the end of the filename.
- //
- if ($animation)
- {
- string $paddingString =
- extractFramePaddingString($originalHwFilename);
- if ($paddingString == "")
- {
- // There is no frame number specification, so we add the
- // frame number specification at the end of the filename.
- //
- $padding = `intFieldGrp -query -value1 framePaddingCtrl`;
- if ($padding <= 1)
- {
- $paddingString = ".%n";
- }
- else
- {
- $paddingString = ".%"+$padding+"n";
- }
-
- // Put the frame number specification string at the
- // end of the filename.
- //
- $originalHwFilename = $originalHwFilename + $paddingString;
- setAttr hardwareRenderGlobals.filename -type "string"
- $originalHwFilename;
-
- // There is a scriptJob which calls this function when
- // the filename attribute is changed. The setAttr
- // code above will trigger this scriptJob again.
- // we do not want to run the code below twice,
- // so we return.
- //
- return;
- }
- }
-
- // Fix filename pattern to make sure the output filenames are unique.
- //
- string $hwFilename = `hwRender -query -fixFileNameNumberPattern`;
-
- string $patternArray[];
- int $itemArray[];
-
- $i = 0;
-
- // Possible pattern: name.#.ext
- //
- $patternArray[$i] = "[.]%[0-9]*n[.]%e$"; $itemArray[$i] = 3; $i=$i+1;
- $patternArray[$i] = "%[.][0-9]*n[.]%e$"; $itemArray[$i] = 3; $i=$i+1;
- $patternArray[$i] = "%[.][0-9]*n%[.]e$"; $itemArray[$i] = 3; $i=$i+1;
- $patternArray[$i] = "[.]%[0-9]*n%[.]e$"; $itemArray[$i] = 3; $i=$i+1;
-
- // Possible pattern: name#.ext
- //
- $patternArray[$i] = "%[0-9]*n%[.]e$"; $itemArray[$i] = 6; $i=$i+1;
- $patternArray[$i] = "%[0-9]*n[.]%e$"; $itemArray[$i] = 6; $i=$i+1;
-
- // Possible pattern: name.ext
- //
- $patternArray[$i] = "[.]%e$"; $itemArray[$i] = 2; $i=$i+1;
- $patternArray[$i] = "%[.]e$"; $itemArray[$i] = 2; $i=$i+1;
-
- // Possible pattern: name.ext.#
- //
- $patternArray[$i] = "[.]%e[.]%[0-9]*n$"; $itemArray[$i] = 4; $i=$i+1;
- $patternArray[$i] = "[.]%e%[.][0-9]*n$"; $itemArray[$i] = 4; $i=$i+1;
- $patternArray[$i] = "%[.]e%[.][0-9]*n$"; $itemArray[$i] = 4; $i=$i+1;
- $patternArray[$i] = "%[.]e[.]%[0-9]*n$"; $itemArray[$i] = 4; $i=$i+1;
-
- // Possible pattern: name.#
- //
- $patternArray[$i] = "[.]%[0-9]*n$"; $itemArray[$i] = 5; $i=$i+1;
- $patternArray[$i] = "%[.][0-9]*n$"; $itemArray[$i] = 5; $i=$i+1;
-
-
-
- // Look for an ending pattern the hwFilename matches with.
- // Initially assume the filename is "custom", until we find a potential
- // matching pattern for the filename ending.
- //
- int $item = 9;
- string $ending = "";
- for ($i = 0; $i < size($patternArray); $i++)
- {
-
- $ending = `match $patternArray[$i] $hwFilename`;
- if ($ending != "")
- {
- $item = $itemArray[$i];
- break;
- }
- }
-
- // If we have not found an ending pattern for the hwFilename yet,
- // the hwFilename might be "name (Single Frame)" or "custom"
- //
- if ($item == 9)
- {
- // Possible pattern: name with no frame number
- //
- if (`match "%[0-9]*n" $hwFilename` == "" &&
- `match "%[-._][0-9]*n" $hwFilename` == "")
- {
- $ending = "";
- $item = 1;
- }
- }
-
- string $prefix;
-
- // When the ending of the file matches a "Frame/Animtion Ext"
- // ending, check if the prefix is just a name or it is part
- // of a custom filename.
- //
- if ($item != 9)
- {
- // Temporarily set the "Frame/Animation Ext" to the item number.
- //
- optionMenuGrp -edit -select $item mayaHardwareExtMenu;
-
- // If it is animation setting, check if the prefix also contains
- // the same frame number pattern as the ending.
- //
- if ( $animation )
- {
- // Extract the frame padding string from the original filename.
- //
- string $paddingString =
- extractFramePaddingString($hwFilename);
-
- // If there is more than one occurrence of this frame number
- // pattern, then it is a custom "Frame/Animation Ext".
- //
- if (`substitute $paddingString $hwFilename ""` !=
- `substituteAll $paddingString $hwFilename ""`)
- {
- $item = 9;
- }
- }
- // If it is not an animation setting, check if the prefix
- // contains any frame number pattern. If it does, it is
- // a custom "Frame/Animation Ext".
- //
- else
- {
- $prefix = `substitute $ending $hwFilename ""`;
-
- // Extract the frame padding string from the prefix.
- //
- string $paddingString =
- extractFramePaddingString($prefix);
-
- if ($paddingString != "")
- {
- $item = 9;
- }
- }
- }
-
- // Separate the prefix from the ending.
- //
-
- if ($item == 9)
- {
- // For custom filename, the prefix is the original filename.
- //
- $prefix = $originalHwFilename;
- menuItem -edit -enable true mayaHardwareCustomFrameExtItem;
- }
- else
- {
- $prefix = `substitute $ending $hwFilename ""`;
- }
-
- // Match the behavior of "File Name Prefix" control to that in
- // software common tab.
- //
- if ($prefix == "")
- {
- $prefix = "%s";
- $hwFilename = $prefix + $ending;
- setAttr -type "string" hardwareRenderGlobals.filename $hwFilename;
- return;
- }
-
- updateMayaHardwareFileNamePrefixControl($prefix);
-
- // Update the "File/Animation Ext" controls.
- //
- optionMenuGrp -edit -select $item mayaHardwareExtMenu;
-
-
- // Extract the frame padding from the filename.
- //
- $padding = extractFramePadding($hwFilename);
-
- // When there is no padding specified, we leave the current
- // frame padding number as it is.
- // When there is a padding number specified, we update the
- // framePaddingCtrl.
- //
- if ($padding > 0)
- {
- intFieldGrp -edit -value1 $padding framePaddingCtrl;
- }
-
- setParent $oldParent;
- }
-
- // Description: This procedure is called when the image format is changed
- // to
- // . either an animation format (multiframe == true),
- // . or a non-animation format (multiframe == false).
- // We need to update the Frame/Animation Ext accordingly.
- //
- proc refreshMayaHardwareFrameAnimationExt(int $multiframe)
- {
- // Enable/Disable Frame/Animtaion extension.
- //
- menuItem
- -edit -enable (!$multiframe)
- mayaHardwareNameDotFrameDotExtension;
- menuItem
- -edit -enable (!$multiframe)
- mayaHardwareNameDotExtensionDotFrame;
- menuItem
- -edit -enable (!$multiframe)
- mayaHardwareNameDotFrame;
- menuItem
- -edit -enable (!$multiframe)
- mayaHardwareNameFrameDotExtension;
- menuItem
- -edit -enable $multiframe
- mayaHardwareNameMultiFrame;
- menuItem
- -edit -enable $multiframe
- mayaHardwareNameDotExtensionMultiFrame;
- menuItem
- -edit -enable false
- -label "custom" mayaHardwareCustomFrameExtItem;
- }
-
- // Description: This procedure is called when the
- // hardwareRenderglobals.filename attribute is changed.
- //
- global proc updateMayaHardwareFilenameRelatedControls()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- // Depending on the new imageFormat is an animation format or a
- // non-animation format, we need to refresh Frame/Animation Ext control.
- //
- int $multiframe = checkMayaHardwareMultiframeFormat();
-
- refreshMayaHardwareFrameAnimationExt($multiframe);
-
- // If the filename is empty, replace it by the default filename.
- //
- string $originalHwFilename = `getAttr "hardwareRenderGlobals.filename"`;
- if ($originalHwFilename == "")
- {
- $originalHwFilename = "%s.%e";
- setAttr -type "string" hardwareRenderGlobals.filename
- $originalHwFilename;
-
- // There is a scriptJob which calls this function when
- // the filename attribute is changed. The setAttr
- // code above will trigger this scriptJob again.
- // we do not want to run the code below twice,
- // so we return.
- //
- return;
- }
-
- // If the format is a multiframe animation format, update related controls.
- //
- if ( $multiframe )
- {
- updateMayaHardwareMultiFrameControls();
- }
- else
- {
- updateMayaHardwareNonMultiFrameControls();
- }
-
- // Update the animation related controls and the use custom file
- // extension controls.
- //
- updateMayaHardwareFrameNumberControls();
- updateMayaHardwareCustomExtension();
-
- setParent $oldParent;
- }
-
- // Description: This procedure is called when the user changes the
- // file name prefix field from the unified render globals window.
- //
- global proc changeMayaHardwareFileNamePrefix()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- string $prefix = `textFieldGrp -query -text mayaHardwareFilePrefix`;
-
- // If the prefix is an empty string,
- // then let the prefix be "default-%s" where "%s" indicates
- // that the scene name should be substituted in here.
- //
- if ($prefix == "")
- {
- $prefix = "%s";
- textFieldGrp -edit -text $prefix mayaHardwareFilePrefix;
- }
-
- // Update the filename change due to the change in prefix.
- //
- mayaHardwareFilenameChange();
-
- setParent $oldParent;
- }
-
- proc createFileNameFormatControl()
- {
- // The Maya Hardware Renderer currently supports only one output filename
- // format. Although we will create a control which shows the same variety
- // of output filename formats other renderers provide, the user will only
- // be able to choose one of the available options.
- //
- optionMenuGrp
- -label "Frame/Animation Ext"
- -changeCommand ("mayaHardwareFilenameChange")
- mayaHardwareExtMenu;
-
- menuItem
- -label "name (Single Frame)";
- menuItem
- -label "name.ext (Single Frame)";
- menuItem
- -label "name.#.ext"
- mayaHardwareNameDotFrameDotExtension;
- menuItem
- -label "name.ext.#"
- mayaHardwareNameDotExtensionDotFrame;
- menuItem
- -label "name.#"
- mayaHardwareNameDotFrame;
- menuItem
- -label "name#.ext"
- mayaHardwareNameFrameDotExtension;
- menuItem
- -label "name (Multi Frame)"
- mayaHardwareNameMultiFrame;
- menuItem
- -label "name.ext (Multi Frame)"
- mayaHardwareNameDotExtensionMultiFrame;
- menuItem
- -label "custom" mayaHardwareCustomFrameExtItem;
-
- // The user is not allowed to choose the item "custom" directly
- // from the "Frame/Animation Ext" control, because it does
- // specify how the filename should be formed differently from
- // the six choices above.
- //
- menuItem -edit -enable false mayaHardwareCustomFrameExtItem;
-
- }
-
- // Description: This procedure is called to change the frame padding
- // information in the filename.
- //
- proc string changeFramePaddingInfoInFilename(string $filename, int $newPadding)
- {
- string $paddingString = extractFramePaddingString($filename);
- string $oldPaddingNumberString = `match "[0-9]*n" $paddingString`;
- string $newPaddingNumberString = $newPadding + "n";
- string $newPaddingString =
- `substitute $oldPaddingNumberString $paddingString $newPaddingNumberString`;
- string $newFilename =
- `substituteAll $paddingString $filename $newPaddingString`;
- return $newFilename;
- }
-
- global proc mayaHardwareFilenameChange()
- //
- // Procedure Name:
- // mayaHardwareFilenameChange
- //
- // Description:
- // This procedure is called when the user changes the format
- // of the file extension. It sets the internal representation
- // and then updates the example to show the changes.
- //
- // Note:
- // Although the user sees only one control to change the
- // extension, it actually affects more than one value.
- //
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $item = `optionMenuGrp -q -sl mayaHardwareExtMenu`;
-
- // Specify the filename pattern.
- //
- string $hwFilename = "";
-
- switch ($item)
- {
- case 1:
- $hwFilename = "name";
- break;
- case 2:
- $hwFilename = "name.%e";
- break;
- case 3:
- $hwFilename = "name.%n.%e";
- break;
- case 4:
- $hwFilename = "name.%e.%n";
- break;
- case 5:
- $hwFilename = "name.%n";
- break;
- case 6:
- $hwFilename = "name%n.%e";
- break;
- case 7:
- $hwFilename = "name";
- break;
- case 8:
- $hwFilename = "name.%e";
- break;
- case 9:
- $hwFilename = "name";
- break;
- }
-
- // When the setting is not custom, set the animation attribute.
- //
- int $animation = true;
- if ($item == 1 || $item == 2)
- {
- $animation = false;
- }
- setAttr defaultRenderGlobals.animation $animation;
-
- if ($item != 9)
- {
- // The new choice is not "custom", so we disable the selection
- // "custom".
- //
- menuItem -edit -enable false mayaHardwareCustomFrameExtItem;
- }
-
- // Only substitute the image frame number for cases where the
- // padding number should be controlled by the "Frame Padding"
- // control.
- //
- if ($item >=3 && $item <= 6)
- {
- // Substitute in the user specified frame padding.
- //
- int $pad = `intFieldGrp -query -value1 framePaddingCtrl`;
-
- if ($pad > 1)
- {
- string $frameNumberString = "%"+$pad+"n";
- $hwFilename = `substitute "%n" $hwFilename $frameNumberString`;
- }
- }
-
- // Substitute in the user specified prefix.
- //
- string $prefix = `textFieldGrp -query -text mayaHardwareFilePrefix`;
- if ($prefix == "(not set; using filename)")
- {
- $prefix = "%s";
- }
- $hwFilename = `substitute "name" $hwFilename $prefix`;
-
- setAttr -type "string" "hardwareRenderGlobals.filename" $hwFilename;
- updateMayaHardwareFilenameRelatedControls;
-
- setParent $oldParent;
- }
-
- proc createHwCompressorControlForMac(int $item)
- {
- global string $imgExt[];
- rowLayout -adjustableColumn true -nc 4 ;
- text -l "";
- button -l "Compression..." -width 80 -enable false -c "movieCompressor -hardwareOptions" renderHwGlobalsCompression;
- text -l "";
- text -l "";
- setParent ..;
- if($imgExt[$item] == "qt"){
- button -e -enable true renderHwGlobalsCompression;
- }
-
- }
-
- proc enableHwMacCompressorbutton(int $item)
- {
- global int $imgExtNum[];
- if(`about -mac`){
- if($imgExtNum[$item] == 22){
- button -e -enable true renderHwGlobalsCompression;
- }else{
- button -e -enable false renderHwGlobalsCompression;
- }
- }
- }
-
- proc createImageFormatControl()
- {
- string $parent = `setParent -query`;
-
- optionMenuGrp
- -label "Image Format"
- -changeCommand "changeMayaHardwareImageFormat"
- hardwareImageMenu;
-
- if (`about -nt`)
- {
- menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6;
- menuItem -label "AVI (avi)"; // $imgExt[1] = "avi"; $imgExtNum[1] = 23;
- menuItem -label "Cineon (cin)"; // $imgExt[2] = "cin"; $imgExtNum[2] = 11;
- menuItem -label "EPS (eps)"; // $imgExt[3] = "eps"; $imgExtNum[3] = 9;
- menuItem -label "GIF (gif)"; // $imgExt[4] = "gif"; $imgExtNum[4] = 0;
- menuItem -label "JPEG (jpeg)"; // $imgExt[5] = "jpeg"; $imgExtNum[5] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[7] = "iff"; $imgExtNum[7] = 10;
- menuItem -label "Quantel (yuv)"; // $imgExt[8] = "yuv"; $imgExtNum[8] = 12;
- menuItem -label "RLA (rla)"; // $imgExt[9] = "rla"; $imgExtNum[9] = 2;
- menuItem -label "SGI (sgi)"; // $imgExt[10] = "sgi"; $imgExtNum[10] = 5;
- menuItem -label "SGI16 (sgi)"; // $imgExt[11] = "sgi"; $imgExtNum[11] = 13;
- menuItem -label "SoftImage (pic)"; // $imgExt[12] = "pic"; $imgExtNum[12] = 1;
- menuItem -label "Targa (tga)"; // $imgExt[13] = "tga"; $imgExtNum[13] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[14] = "tif"; $imgExtNum[14] = 3;
- menuItem -label "Tiff16 (tif)"; // $imgExt[15] = "tif"; $imgExtNum[15] = 4;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[16] = "bmp"; $imgExtNum[16] = 20;
- }
- else if (`about -irix`)
- {
- menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6;
- menuItem -label "AVI (avi)"; // $imgExt[1] = "avi"; $imgExtNum[1] = 23;
- menuItem -label "Cineon (cin)"; // $imgExt[2] = "cin"; $imgExtNum[2] = 11;
- menuItem -label "EPS (eps)"; // $imgExt[3] = "eps"; $imgExtNum[3] = 9;
- menuItem -label "GIF (gif)"; // $imgExt[4] = "gif"; $imgExtNum[4] = 0;
- menuItem -label "JPEG (jpeg)"; // $imgExt[5] = "jpeg"; $imgExtNum[5] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[7] = "iff"; $imgExtNum[7] = 10;
- menuItem -label "Quantel (yuv)"; // $imgExt[8] = "yuv"; $imgExtNum[8] = 12;
- menuItem -label "Quicktime (qt)"; // $imgExt[9] = "qt"; $imgExtNum[9] = 22;
- menuItem -label "RLA (rla)"; // $imgExt[10] = "rla"; $imgExtNum[10] = 2;
- menuItem -label "SGI (sgi)"; // $imgExt[11] = "sgi"; $imgExtNum[11] = 5;
- menuItem -label "SGI16 (sgi)"; // $imgExt[12] = "sgi"; $imgExtNum[12] = 13;
- menuItem -label "SGI Movie (mv)"; // $imgExt[13] = "mv"; $imgExtNum[13] = 21;
- menuItem -label "SoftImage (pic)"; // $imgExt[14] = "pic"; $imgExtNum[14] = 1;
- menuItem -label "Targa (tga)"; // $imgExt[15] = "tga"; $imgExtNum[15] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[16] = "tif"; $imgExtNum[16] = 3;
- menuItem -label "Tiff16 (tif)"; // $imgExt[17] = "tif"; $imgExtNum[17] = 4;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[18] = "bmp"; $imgExtNum[18] = 20;
- }
- else if (`about -linux`)
- {
- menuItem -label "Alias PIX (als)"; // $imgExt[0] = "als"; $imgExtNum[0] = 6;
- menuItem -label "Cineon (cin)"; // $imgExt[1] = "cin"; $imgExtNum[1] = 11;
- menuItem -label "EPS (eps)"; // $imgExt[2] = "eps"; $imgExtNum[2] = 9;
- menuItem -label "GIF (gif)"; // $imgExt[3] = "gif"; $imgExtNum[3] = 0;
- menuItem -label "JPEG (jpeg)"; // $imgExt[4] = "jpeg"; $imgExtNum[4] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[5] = "iff"; $imgExtNum[5] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[6] = "iff"; $imgExtNum[6] = 10;
- menuItem -label "Quantel (yuv)"; // $imgExt[7] = "yuv"; $imgExtNum[7] = 12;
- menuItem -label "RLA (rla)"; // $imgExt[8] = "rla"; $imgExtNum[8] = 2;
- menuItem -label "SGI (sgi)"; // $imgExt[9] = "sgi"; $imgExtNum[9] = 5;
- menuItem -label "SGI16 (sgi)"; // $imgExt[10] = "sgi"; $imgExtNum[10] = 13;
- menuItem -label "SoftImage (pic)"; // $imgExt[11] = "pic"; $imgExtNum[11] = 1;
- menuItem -label "Targa (tga)"; // $imgExt[12] = "tga"; $imgExtNum[12] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[13] = "tif"; $imgExtNum[13] = 3;
- menuItem -label "Tiff16 (tif)"; // $imgExt[14] = "tif"; $imgExtNum[14] = 4;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[15] = "bmp"; $imgExtNum[15] = 20;
- }
- else if (`about -mac`)
- {
- menuItem -label "JPEG (jpeg)"; // $imgExt[0] = "jpeg"; $imgExtNum[0] = 8;
- menuItem -label "Maya IFF (iff)"; // $imgExt[1] = "iff"; $imgExtNum[1] = 7;
- menuItem -label "Maya16 IFF (iff)"; // $imgExt[2] = "iff"; $imgExtNum[2] = 10;
- menuItem -label "MacPaint (pntg)"; // $imgExt[3] = "pntg"; $imgExtNum[3] = 30;
- menuItem -label "Photoshop (ps)"; // $imgExt[4] = "ps"; $imgExtNum[4] = 31;
- menuItem -label "PNG (png)"; // $imgExt[5] = "png"; $imgExtNum[5] = 32;
- menuItem -label "QuickDraw (pict)"; // $imgExt[6] = "pict"; $imgExtNum[6] = 33;
- menuItem -label "Quicktime Movie (qt)"; // $imgExt[7] = "qt"; $imgExtNum[7] = 22;
- menuItem -label "Quicktime Image (qtif)";// $imgExt[8] = "qtif"; $imgExtNum[8] = 34;
- menuItem -label "Silicon Graphics (sgi)";// $imgExt[9] = "sgi"; $imgExtNum[9] = 5;
- menuItem -label "Targa (tga)"; // $imgExt[10] = "tga"; $imgExtNum[10] = 19;
- menuItem -label "Tiff (tif)"; // $imgExt[11] = "tif"; $imgExtNum[11] = 3;
- menuItem -label "Windows Bitmap (bmp)"; // $imgExt[12] = "bmp"; $imgExtNum[12] = 20;
- optionMenuGrp -e -sl 2 hardwareImageMenu;
- }
- else
- {
- warning "Unsupported platform in unifiedRenderGlobalsWindow.mel";
- }
-
- scriptJob
- -parent $parent
- -attributeChange
- "hardwareRenderGlobals.imageFormat"
- "updateMayaHardwareImageFormatControl";
- }
-
-
- global proc updateMayaHardwareImageFormatControl()
- {
- string $oldParent = `setParent -query`;
- setParentToCommonTab();
-
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $imageNum = `getAttr "hardwareRenderGlobals.imageFormat"`;
-
- for ($i=0; $i < size($imgExtNum); ++$i)
- {
- if ($imageNum == $imgExtNum[$i])
- {
- optionMenuGrp -edit -sl ($i+1) hardwareImageMenu;
- enableHwMacCompressorbutton($i);
- break;
- }
- }
-
- // Update how the filename will be interpreted.
- //
- updateMayaHardwareFilenameRelatedControls;
-
- setParent $oldParent;
- }
-
- global proc changeMayaHardwareImageFormat()
- {
- //
- // Procedure Name:
- // changeImageFormat
- //
- // Description:
- // This procedure is called when the user changes the type of
- // image that will be written out. It sets the internal
- // representation and then updates the example to show the changes.
- //
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- global string $imgExt[]; // This is the actual file extension
- global int $imgExtNum[]; // This is the corresponding internal value
-
- int $item = `optionMenuGrp -q -sl hardwareImageMenu` - 1;
-
-
- setAttr hardwareRenderGlobals.imageFormat $imgExtNum[$item];
-
- enableHwMacCompressorbutton($item);
-
- // Check if the image format is IFF.
- //
- // Note: there are two IFF image types. One for 8 bit images
- // and one for 16 bit images. They both have an imgExt of iff.
-
- /* if ($imgExt[$item] != "iff")
- {
- int $useBlur = `getAttr hardwareRenderGlobals.motionBlur`;
- int $blur2d = (`getAttr hardwareRenderGlobals.motionBlurType` == 0);
- int $keepMotionVector = (`getAttr hardwareRenderGlobals.keepMotionVector` == 1);
- if ($useBlur && $blur2d && $keepMotionVector)
- {
- warning
- ("Non-IFF image formats are not supported when writing"+
- " 2D motion vectors; setting image format to IFF");
-
- // Set globals imageFormat to Maya IFF
- setAttr hardwareRenderGlobals.imageFormat 7;
- }
- }
-
- $item = `optionMenuGrp -q -sl hardwareImageMenu` - 1;
- int $multiframe = multiframeFormat($imgExt[$item]);
-
- if ( $multiframe )
- {
- setAttr defaultRenderGlobals.animation 1;
- }
-
- // Update the batch render window if it exists.
- if (`exists updateBatchRenderWindowTitle`)
- {
- updateBatchRenderWindowTitle();
- }*/
-
- setParent $oldParent;
- }
-
-
- proc createCameraControl()
- {
- //Note: not updating if changed elsewhere
- //
- optionMenuGrp
- -label "Camera"
- -changeCommand changeMayaHardwareCamera
- mayaHardwareCameraMenu;
- }
-
-
- global proc updateMayaHardwareCameraControl()
- {
- string $oldParent = `setParent -query`;
-
- setParentToCommonTab();
-
- // This is a fix to get around the optionMenuGrp bug (#81337)
- string $fullName = `setParent "mayaHardwareCameraMenu"`;
- string $menuName = ($fullName+"|OptionMenu");
- setParent -m $menuName;
-
- string $allCameras[] = `ls -cameras`;
- string $parents[];
- int $i;
- int $numRenderable = 0;
- string $cmd;
-
- //
- // First remove any existing menuItems; we're gonna rebuild the menu
- // from scratch each time.
-
- int $numOldMenuItems = `optionMenuGrp -q -ni mayaHardwareCameraMenu`;
- string $oldMenuItems[] = `optionMenuGrp -q -ill mayaHardwareCameraMenu`;
-
- for ($i = 0; $i < $numOldMenuItems; $i++)
- {
- deleteUI $oldMenuItems[$i];
- }
-
- // Run through the list of all of the cameras and build a
- // optionMenu of them that the user uses to select the
- // renderable camera.
- //
- // First count how many renderable cameras exist
- //
- for ($i = 0; $i < size($allCameras); $i++)
- {
- if (`getAttr ($allCameras[$i] + ".renderable")`)
- {
- $numRenderable++;
- }
- }
-
- int $firstRenderable = 0;
- for ($i = 0; $i < size($allCameras); $i++)
- {
- $parents = `listRelatives -path -parent $allCameras[$i]`;
- string $thisLabel = `menuItem -label $parents[0]`;
- // Use the first renderable camera
- if (`getAttr ($allCameras[$i] + ".renderable")`)
- {
- $firstRenderable++;
- if ($firstRenderable == 1)
- {
- // Selected Camera -----------------------------------------
- optionMenuGrp -edit -sl ($i+1) mayaHardwareCameraMenu;
- }
- if ($numRenderable > 1)
- {
- string $camLabel = $parents[0] + " (Renderable)";
- menuItem -edit -label $camLabel $thisLabel;
- }
- }
- }
-
- setParent $oldParent;
- }
-
- global proc changeMayaHardwareCamera()
- {
- //
- // Procedure Name:
- // switchCamera
- //
- // Description:
- // This procedure is called when the user changes the camera
- // that will be rendered.
- // It updates the controls for the new camera
- //
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- //
- // First count how many renderable cameras exist
- //
- string $allCameras[] = `ls -cameras`;
-
- int $numRenderable = 0;
-
- for ($i = 0; $i < size($allCameras); $i++)
- {
- if (`getAttr ($allCameras[$i] + ".renderable")`)
- {
- $numRenderable++;
- }
- }
-
- int $camIndex = `optionMenuGrp -query -select mayaHardwareCameraMenu` - 1;
-
- if ($numRenderable < 2)
- {
- for ($i = 0; $i < size($allCameras); $i++)
- {
- if ($i == $camIndex)
- {
- setAttr ($allCameras[$i] + ".renderable") 1;
- }
- else
- {
- setAttr ($allCameras[$i] + ".renderable") 0;
- }
- }
- }
-
- // Connect the channel controls to the new camera
- //
- string $whichCamera = $allCameras[$camIndex];
- attrControlGrp -edit -attribute ($whichCamera + ".mask") alphaChannel;
- attrControlGrp -edit -attribute ($whichCamera + ".depth") depthChannel;
-
- // Fix for 160069. The mental ray renderer and the Maya renderer
- // use the same renderable camera, so the mental ray render globals and
- // the Maya render globals must be kept in sync when the renderable camera
- // changes. The following code causes the attribute editor to be
- // refreshed, just in case it contains the mental ray render globals.
- //
- global string $gAEFocusNode;
- updateAE($gAEFocusNode);
-
- // When the camera is changed, update the example file name.
- //
- updateMayaHardwareTargetFilePreview;
-
- setParent $oldParent;
- }
-
- global proc changeMayaHardwareRenderableObjectCtrl()
- {
- int $item = `optionMenuGrp -q -sl renderableObjectCtrl`;
-
- global string $hardwareRenderSelectedFlag;
- $hardwareRenderSelectedFlag = "";
-
- if ($item == 2)
- {
- $hardwareRenderSelectedFlag = "-renderSelected";
- }
- }
-
- proc updateMayaHardwareRenderableObjectCtrl()
- {
- //
- // Description:
- // This procedure is called when Renderable Object control needs to be
- // refreshed.
- // This procedure updates the Renderable Object control to reflect the
- // current value of the flag which represents the value of the control.
- //
-
- global string $hardwareRenderSelectedFlag;
-
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- if ($hardwareRenderSelectedFlag == "-renderSelected")
- {
- // Select "Render Active" in the Renderable Objects option menu
- //
- optionMenuGrp -edit -select 2 renderableObjectCtrl;
- }
- else
- {
- // Select "Render All" in the Renderable Objects option menu
- //
- optionMenuGrp -edit -select 1 renderableObjectCtrl;
- }
-
- setParent $oldParent;
- }
-
- // Description: This procedure is called when we need enable/disable
- // animation frame number or frame padding related controls.
- //
- global proc updateMayaHardwareFrameNumberControls()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- int $multiframe = checkMayaHardwareMultiframeFormat();
- int $useAnim = `getAttr defaultRenderGlobals.animation`;
-
- attrControlGrp -edit -enable $useAnim mayaHardwareStartFrameCtrl;
- attrControlGrp -edit -enable $useAnim mayaHardwareEndFrameCtrl;
- attrControlGrp -edit -enable $useAnim mayaHardwareByFrameCtrl;
-
- attrControlGrp -edit -enable ($useAnim && !$multiframe)
- mayaHardwareRenumberFrameCtrl;
- intFieldGrp -edit -enable ($useAnim && !$multiframe) framePaddingCtrl;
-
-
- int $renumberFrames = `getAttr "hardwareRenderGlobals.modifyExtension"`;
- $renumberFrames = $renumberFrames && $useAnim && !$multiframe;
-
- attrControlGrp
- -edit
- -enable $renumberFrames
- startExtensionCtrl;
- attrControlGrp
- -edit
- -enable $renumberFrames
- byExtensionCtrl;
-
- updateMayaHardwareTargetFilePreview();
-
- setParent $oldParent;
- }
-
- // Description: This procedure is called when the frame padding is changed
- // by the user from the unified render globals.
- //
- global proc mayaHardwareFramePaddingChanged()
- {
- // If the "Frame/Animation Ext" is set to "custom", then the
- // filename == the prefix, so we need to change the frame
- // padding information in the prefix.
- //
- int $item = `optionMenuGrp -q -sl mayaHardwareExtMenu`;
- if ($item == 9)
- {
- int $pad = `intFieldGrp -query -value1 framePaddingCtrl`;
- if ($pad < 1)
- {
- $pad = 1;
- intFieldGrp -edit -value1 $pad framePaddingCtrl;
- }
-
- string $prefix = `textFieldGrp -query -text mayaHardwareFilePrefix`;
- $prefix = changeFramePaddingInfoInFilename($prefix, $pad);
- textFieldGrp -edit -text $prefix mayaHardwareFilePrefix;
- }
-
- mayaHardwareFilenameChange;
- updateMayaHardwareTargetFilePreview;
- }
-
- proc createCommonImageFile()
- //
- // Procedure Name:
- // createCommonImageFile
- //
- // Description:
- // Creates the UI in the "Image File Output" expand/collapse section.
- // This section is always created so is treated differently
- // then the sections created when the tab is expanded.
- //
- {
- string $parent = `setParent -query`;
-
- setUITemplate -pushTemplate attributeEditorTemplate;
-
- global string $imgExt[];
-
- if (size( $imgExt ) == 0)
- {
- // If the file format array has not been initialized yet, do so.
- // This routine may be called in dynPaintMenus.mel during the
- // file save for PFX canvas images.
- createImageFormats();
- }
-
- columnLayout -adjustableColumn true;
-
- createFileNamePrefixControl();
- createFileNameFormatControl();
- createImageFormatControl();
- if(`about -mac`){
- int $item = `optionMenuGrp -q -sl hardwareImageMenu` - 1;
- createHwCompressorControlForMac($item);
- }
-
- separator;
-
- // Frame numbers ------------------------------------------------
-
- attrControlGrp
- -attribute hardwareRenderGlobals.startFrame
- -cc "updateMayaHardwareTargetFilePreview"
- -hideMapButton true
- -label "Start Frame"
- mayaHardwareStartFrameCtrl;
- attrControlGrp
- -attribute hardwareRenderGlobals.endFrame
- -cc "updateMayaHardwareTargetFilePreview"
- -hideMapButton true
- -label "End Frame"
- mayaHardwareEndFrameCtrl;
- attrControlGrp
- -attribute hardwareRenderGlobals.byFrame
- -hideMapButton true
- -label "By Frame"
- mayaHardwareByFrameCtrl;
-
- intFieldGrp
- -label "Frame Padding"
- -value1 1
- -cc "mayaHardwareFramePaddingChanged()"
- framePaddingCtrl;
-
- separator;
-
- // Renderable Objects ------------------------------------------------
-
- optionMenuGrp
- -label "Renderable Objects"
- -cc "changeMayaHardwareRenderableObjectCtrl"
- renderableObjectCtrl;
-
- menuItem -label "Render All";
- menuItem -label "Render Active";
-
- changeMayaHardwareRenderableObjectCtrl();
-
- // Cameras ------------------------------------------------
-
- createCameraControl();
- updateMayaHardwareCameraControl();
-
- // Channels ------------------------------------------------
-
- string $currentCamera = `optionMenuGrp -q -v mayaHardwareCameraMenu`;
- //
- // Remove the substring " (Renderable)" from the string
- // $currentCamera if there is any.
- //
- $currentCamera = `substitute " .*" $currentCamera ""`;
- string $camShapes[] = `listRelatives -path -shapes $currentCamera`;
- $currentCamera = $camShapes[0];
-
- // With the Maya Hardware Renderer, you do not have the option of
- // not outputting color. Therefore we will show the user that the color
- // channel is on, but we won't allow them to change it.
- //
- checkBoxGrp
- -label "Channels"
- -label1 "RGB Channel (Color)"
- -ann "Not available for this renderer"
- -value1 true -enable false;
-
- attrControlGrp
- -label "Alpha Channel (Mask)"
- -attribute ($currentCamera + ".mask")
- alphaChannel;
- attrControlGrp
- -label "Depth Channel (Z Depth)"
- -attribute ($currentCamera + ".depth")
- depthChannel;
-
- // The Maya Hardware Renderer does not support a custom extension, so
- // although we create controls for custom extension which look the same
- // as they do for other renderers, these controls will remain disabled.
- //
- frameLayout
- -collapsable true
- -collapse true
- -label "Custom Extension";
-
- columnLayout;
-
- attrControlGrp
- -cc "updateMayaHardwareCustomExtension"
- -attribute hardwareRenderGlobals.useCustomExtension
- mayaHardwareUseCustomExtionsionCtrl;
-
- attrControlGrp
- -label ""
- -attribute hardwareRenderGlobals.customExtension
- mayaHardwareCustomExtensionCtrl;
-
-
- updateMayaHardwareCustomExtension();
-
- setParent ..;
- setParent ..;
-
- // Frame renumbering tab
- //
- frameLayout
- -collapsable true
- -collapse true
- -label "Renumber Frames";
-
- columnLayout;
- attrControlGrp
- -attribute hardwareRenderGlobals.modifyExtension
- -changeCommand "updateMayaHardwareFrameNumberControls"
- -label "Renumber Frames Using:"
- mayaHardwareRenumberFrameCtrl;
- attrControlGrp
- -attribute hardwareRenderGlobals.startExtension
- -enable (`getAttr hardwareRenderGlobals.modifyExtension`)
- -cc "updateMayaHardwareTargetFilePreview"
- -hideMapButton true
- -label "Start Number" startExtensionCtrl;
- attrControlGrp
- -attribute hardwareRenderGlobals.byExtension
- -enable (`getAttr hardwareRenderGlobals.modifyExtension`)
- -cc "updateMayaHardwareTargetFilePreview"
- -hideMapButton true
- -label "By Frame" byExtensionCtrl;
- setParent ..;
- setParent ..;
-
- setParent $parent;
- setUITemplate -popTemplate;
-
- // Perform an initial update of the UI created above, so that controls
- // which are not directly connected to attributes are properly initialized.
- //
- updateMayaHardwareFilenameRelatedControls;
- updateMayaHardwareImageFormatControl();
- // updateMayaHardwareUseCustomExtensionControl();
- // updateMayaHardwareCustomExtensionControl();
- // updateMayaHardwareAlphaChannelControl();
- // updateMayaHardwareDepthChannelControl();
- }
-
- global proc updateMayaHardwareCustomExtension()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- // When the "Frame/Animation Ext" does not involve frame extension,
- // gray out "Using Custom Extension".
- //
- int $useExtension = true;
- int $item = `optionMenuGrp -q -select mayaHardwareExtMenu`;
- if ($item == 1 || $item == 5)
- {
- $useExtension = false;
- }
-
- attrControlGrp -edit -enable $useExtension
- mayaHardwareUseCustomExtionsionCtrl;
-
- // The custom extension field is enabled only when we need frame
- // extension and the "Use Custom Extension" is on.
- //
- int $modifyExt = `getAttr hardwareRenderGlobals.useCustomExtension`;
- $modifyExt = $modifyExt && $useExtension;
- attrControlGrp -edit -enable $modifyExt mayaHardwareCustomExtensionCtrl;
-
- setParent $oldParent;
- }
-
- //==================================================================
- // Hardware Common Tab
- //==================================================================
-
- global proc updateMayaHardwareCommonGlobalsTab()
- {
- //
- // Description:
- // This procedure is called when the current renderer changes to be the
- // Maya Hardware Renderer.
- // This procedure updates the UI of the common tab to reflect any values
- // which may have been copied from the previous current renderer.
- //
-
- updateMayaHardwareFilenameRelatedControls;
- updateMayaHardwareRenderableObjectCtrl();
- updateMayaHardwareCameraControl();
- updateMayaHardwareResolution();
- updateMayaHardwareTargetFilePreview();
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the Render Options frame
- //
- proc createMayaHardwareCommonRenderOptions()
- {
- string $parent = `setParent -query`;
-
- setUITemplate -pushTemplate attributeEditorTemplate;
-
- columnLayout -adjustableColumn true;
-
- attrControlGrp
- -attribute "hardwareRenderGlobals.enableDefaultLight";
-
- textFieldGrp -label "Plug-in Format"
- -tx "Not available for this renderer"
- -enable false;
-
- attrControlGrp
- -attribute hardwareRenderGlobals.preRenderMel
- -label "Pre Render MEL"
- preRenderMelHwGrp;
-
- attrControlGrp
- -attribute hardwareRenderGlobals.postRenderMel
- -label "Post Render MEL"
- postRenderMelHwGrp;
-
- if (`about -evalVersion`)
- {
- attrControlGrp -e -enable false preRenderMelHwGrp;
- attrControlGrp -e -enable false postRenderMelHwGrp;
- }
-
- setParent $parent;
- setUITemplate -popTemplate;
- }
-
- global proc createMayaHardwareCommonGlobalsTab()
- {
- //
- // Description:
- // This procedure builds the "Common" tab for the Maya Hardware renderer.
- //
-
- string $renderer = "mayaHardware";
-
- string $parentForm = `setParent -query`;
-
- createTargetFilePreview();
-
- setParent $parentForm;
-
- scrollLayout
- -horizontalScrollBarThickness 0
- scrollLayout;
-
- columnLayout
- -adjustableColumn true
- commonTabColumn;
-
- // Image File Name
- //
- frameLayout
- -label "Image File Output"
- -collapsable true
- -collapse false
- rgImageFileFrame;
-
- createCommonImageFile();
-
- setParent commonTabColumn;
-
- // Resolution Section
- //
- frameLayout
- -label "Resolution"
- -collapsable true
- -collapse false
- rgResolutionFrame;
-
- createMayaHardwareCommonResolution();
-
- setParent commonTabColumn;
-
- // Render Options
- //
- frameLayout
- -label "Render Options"
- -collapsable true
- -collapse false
- rgOptionFrame;
-
- createMayaHardwareCommonRenderOptions();
-
- setParent commonTabColumn;
-
- setParent $parentForm;
-
- formLayout
- -edit
- -af mayaHardwareTargetFilePreview "top" 5
- -an mayaHardwareTargetFilePreview "bottom"
- -af mayaHardwareTargetFilePreview "left" 0
- -af mayaHardwareTargetFilePreview "right" 0
- -ac scrollLayout "top" 5 mayaHardwareTargetFilePreview
- -af scrollLayout "bottom" 0
- -af scrollLayout "left" 0
- -af scrollLayout "right" 0
- $parentForm;
-
- // Update the TargetFilePreview at the end, because it
- // uses a number of controls in the Image File Output
- // frame.
- //
- updateMayaHardwareTargetFilePreview();
- }
-
- // ----------------------------------------------------------------------------
- // Code to create and update the Resolution frame
- //
-
- global proc createMayaHardwareCommonResolution()
- //
- // Procedure Name:
- // createMayaHardwareCommonResolution
- //
- // Description:
- // Creates the UI in the "Resolution" expand/collapse section.
- //
- {
- //
- // Make sure the list of predefined resolutions has been read in.
- //
- global string $gImageFormatData[];
- global string $gUserImageFormatData[];
-
- if (size($gImageFormatData) == 0)
- {
- eval("source imageFormats");
- }
-
- int $isMayaEvalVersion = `about -ev`;
- global string $gPLEImageFormatData[];
- if ($isMayaEvalVersion)
- {
- $gImageFormatData = $gPLEImageFormatData;
- }
-
- if (exists("userImageFormats.mel") && size($gUserImageFormatData) == 0)
- {
- // Yes, we need the eval here, to avoid doing the source
- // until we know whether the file actually exists
- eval("source userImageFormats");
- }
-
- setUITemplate -pushTemplate attributeEditorTemplate;
-
- // If the UI is created already then just update the attribute values.
- if (`columnLayout -exists rgMayaHardwareResolutionLayout`)
- {
- updateMayaHardwareResolution;
- return;
- }
-
- columnLayout -adjustableColumn true rgMayaHardwareResolutionLayout;
- int $resItem;
- int $numResolutionPresets = size($gImageFormatData);
- int $numUserResolutionPresets = size($gUserImageFormatData);
- string $allResNodes[] = `ls -type resolution`;
- int $numResolutionNodePresets = size($allResNodes) - 1;
- int $numTokens;
- string $tokens[];
- string $niceName;
- int $enablePresetItem;
- int $presetWidth;
- int $presetHeight;
-
- optionMenuGrp
- -label "Presets"
- -changeCommand "changeMayaHardwareResolution"
- resolutionMenu;
-
- menuItem -label "Custom";
- for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++)
- {
- string $item = $gImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
-
- // Change any underscore into a space;
- // some names may have up to 2 underscores in them,
- // so we do this twice.
- //
- $niceName = `substitute "_" $tokens[0] " "`;
- $niceName = `substitute "_" $niceName " "`;
-
- // Grey out the presets where the width or the height
- // is more than 2048 for hardware rendering.
- //
- $presetWidth = $tokens[1];
- $presetHeight = $tokens[2];
- $enablePresetItem = true;
- if ($presetWidth > 2048 || $presetHeight > 2048)
- {
- $enablePresetItem = false;
- }
- menuItem -label $niceName -enable $enablePresetItem;
- }
- for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++)
- {
- string $item = $gUserImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
-
- // Change any underscore into a space;
- // some names may have up to 2 underscores in them,
- // so we do this twice.
- //
- $niceName = `substitute "_" $tokens[0] " "`;
- $niceName = `substitute "_" $niceName " "`;
-
- // Grey out the presets where the width or the height
- // is more than 2048 for hardware rendering.
- //
- $presetWidth = $tokens[1];
- $presetHeight = $tokens[2];
- $enablePresetItem = true;
- if ($presetWidth > 2048 || $presetHeight > 2048)
- {
- $enablePresetItem = false;
- }
-
- menuItem -label $niceName -enable $enablePresetItem;
- }
- for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++)
- {
- menuItem -label $allResNodes[$resItem + 1];
- }
-
- separator;
-
- // This attribute is not yet supported by the Maya Hardware Renderer.
- // Once it becomes supported, this control can be enabled, updated, and
- // hooked up with a change command.
- //
- checkBoxGrp -numberOfCheckBoxes 1
- -label1 "Maintain Width/Height Ratio"
- -value1 false
- -cc "checkMayaHardwareAspectLock"
- aspectLockCheck;
-
- intFieldGrp -label "Width"
- -changeCommand "changeMayaHardwareAspectLockWidth"
- mayaHardwareResWidth;
- intFieldGrp -label "Height"
- -changeCommand "changeMayaHardwareAspectLockHeight"
- mayaHardwareResHeight;
-
- scriptJob
- -parent mayaHardwareResWidth
- -attributeChange
- "hardwareRenderGlobals.resolutionX"
- "intFieldGrp -e -v1 `getAttr hardwareRenderGlobals.resolutionX` mayaHardwareResWidth; changeMayaHardwareAspectLockWidth";
-
- scriptJob
- -parent mayaHardwareResHeight
- -attributeChange
- "hardwareRenderGlobals.resolutionY"
- "intFieldGrp -e -v1 `getAttr hardwareRenderGlobals.resolutionY` mayaHardwareResHeight; changeMayaHardwareAspectLockHeight";
-
- separator;
-
- // This attribute is not yet supported by the Maya Hardware Renderer.
- // Once it becomes supported, this control can be enabled, updated, and
- // hooked up with a change command.
- //
- checkBoxGrp
- -annotation "Not available for this renderer"
- -enable false
- -numberOfCheckBoxes 1
- -label1 "Lock Device Aspect Ratio"
- -value1 false
- ratioLockCheck;
-
- // This attribute is not yet supported by the Maya Hardware Renderer.
- // Once it becomes supported, this control can be enabled, updated, and
- // hooked up with a change command.
- //
- floatFieldGrp
- -annotation "Not available for this renderer"
- -label "Device Aspect Ratio"
- -enable false
- -numberOfFields 1
- resRatio;
-
- // This attribute is not yet supported by the Maya Hardware Renderer.
- // Once it becomes supported, this control can be enabled, updated, and
- // hooked up with a change command.
- //
- attrControlGrp
- -attribute "hardwareRenderGlobals.pixelAspectRatio"
- -hideMapButton true
- -changeCommand "adjustMayaHardwareDeviceAspect; updateMayaHardwareResolution";
-
- adjustMayaHardwareDeviceAspect();
-
- // Temporary fix for bug 184921:
- // Set up script job for resolution gate update.
- //
- string $attrArray[];
-
- $attrArray[size($attrArray)] =
- "hardwareRenderGlobals.resolutionX";
- $attrArray[size($attrArray)] =
- "hardwareRenderGlobals.resolutionY";
- $attrArray[size($attrArray)] =
- "hardwareRenderGlobals.pixelAspectRatio";
-
- // Now we establish scriptJobs to invoke the procedure
- // which updates the maya software attribute that effects the
- // "camera settings --> resolution gate".
- //
- int $i;
-
- for ($i = 0; $i < size($attrArray); $i++)
- {
- scriptJob
- -attributeChange
- $attrArray[$i]
- "copyAttrForResolutionGate(\"mayaHardware\")"
- -parent rgMayaHardwareResolutionLayout;
- }
-
- setParent ..;
- setUITemplate -popTemplate;
-
- // Make sure the values are right
- updateMayaHardwareResolution;
-
- // Make sure the values are updated on file new
- //
- scriptJob
- -parent `setParent -query`
- -event "NewSceneOpened" "updateMayaHardwareResolution";
- }
-
-
- global proc updateMayaHardwareResolution()
- //
- // Procedure Name:
- // updateResolution
- //
- // Description:
- // Gets the real values from the nodes and sets the UI based
- // on these values. This procedure updates all of the resolution
- // values.
- //
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- int $width = `getAttr hardwareRenderGlobals.resolutionX`;
- int $height = `getAttr hardwareRenderGlobals.resolutionY`;
- float $deviceAspectRatio= `getAttr hardwareRenderGlobals.pixelAspectRatio`;
- $deviceAspectRatio *= $width;
- $deviceAspectRatio /= $height;
-
- int $resItem;
- int $whichRes = 1; // use "Custom" if no match is found
- string $allResNodes[] = `ls -type resolution`;
-
- global string $gImageFormatData[];
- global string $gUserImageFormatData[];
- int $numResolutionPresets = size($gImageFormatData);
- int $numUserResolutionPresets = size($gUserImageFormatData);
- int $numResolutionNodePresets = size($allResNodes) - 1;
- int $resWidth;
- int $resHeight;
- float $resAspect;
- int $numTokens;
- string $tokens[];
-
- for ($resItem = 0; $resItem < $numResolutionPresets; $resItem++)
- {
- string $item = $gImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
- if ($numTokens == 4)
- {
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- if ($width == $resWidth && $height == $resHeight
- && abs($deviceAspectRatio - $resAspect) < 0.001)
- {
- // We add _2_ to $resItem below: 1 because we're
- // skipping the first item (Custom) in the list, and 1
- // because the optionMenu items are numbered starting at 1,
- // but our list in $gImageFormatData is indexed starting at 0.
- $whichRes = $resItem + 2;
- break;
- }
- }
- else
- {
- warning(
- "Found invalid image format description: \""
- + $item
- + "\" in imageFormats.mel");
- }
- }
-
- // If no match was found in the built-in resolutions,
- // check out the user-defined ones
- //
- if ($whichRes == 1)
- {
- for ($resItem = 0; $resItem < $numUserResolutionPresets; $resItem++)
- {
- string $item = $gUserImageFormatData[$resItem];
- $numTokens = tokenize($item, $tokens);
- if ($numTokens == 4)
- {
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
-
- if ($width == $resWidth && $height == $resHeight
- && abs($deviceAspectRatio - $resAspect) < 0.001)
- {
- $whichRes = $numResolutionPresets + $resItem + 2;
- break;
- }
- }
- else
- {
- warning(
- "Found invalid image format description: \""
- + $item
- + "\" in userImageFormats.mel");
- }
- }
- }
-
- // If no match was found in the user-defined resolutions,
- // see if there are any 'extra' resolution nodes in the scene.
- //
- if ($whichRes == 1)
- {
- for ($resItem = 0; $resItem < $numResolutionNodePresets; $resItem++)
- {
- // We assume the 0th item in the list of resolution nodes is
- // the default one, which is created implicitly...
- //
- string $resNodeName = $allResNodes[$resItem + 1];
-
- $resWidth = `getAttr ($resNodeName + ".resolutionX")`;
- $resHeight = `getAttr ($resNodeName + ".resolutionY")`;
- $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`;
-
- // if ($width == $resWidth && $height == $resHeight
- // && abs($deviceAspectRatio - $resAspect) < 0.001)
- if ($width == $resWidth && $height == $resHeight)
- {
- // We add _2_ to $resItem below: 1 because we're
- // skipping the first item (Custom) in the list, and 1
- // because the optionMenu items are numbered starting at 1,
- // but our list in $gImageFormatData is indexed starting at 0.
- //
- $whichRes = $numResolutionPresets
- + $numUserResolutionPresets + $resItem + 2;
- break;
- }
- }
- }
- optionMenuGrp -edit -sl $whichRes resolutionMenu;
-
- intFieldGrp -edit -v1 $width mayaHardwareResWidth;
- intFieldGrp -edit -v1 $height mayaHardwareResHeight;
- // floatFieldGrp -edit -v1 $deviceAspectRatio resRatio;
-
- setParent $oldParent;
- }
-
- global proc changeMayaHardwareResolution()
- //
- // Procedure Name:
- // changeResolution
- //
- // Description:
- // This procedure is called when the user selects a different
- // resolution. It sets the internal representation
- // and then updates the example to show the changes.
- //
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- global string $gImageFormatData[];
- global string $gUserImageFormatData[];
- int $numResolutionPresets = size($gImageFormatData);
- int $numUserResolutionPresets = size($gUserImageFormatData);
- string $allResNodes[] = `ls -type resolution`;
- int $numResolutionNodePresets = size($allResNodes) - 1;
- string $tokens[];
- int $resItem = `optionMenuGrp -q -sl resolutionMenu`;
- int $resWidth;
- int $resHeight;
- float $resAspect;
- string $item;
-
- // Item #1 is Custom, which doesn't change the fields
- // We subtract _2_ from $resItem below: 1 because we're
- // skipping the first item (Custom) in the list, and 1
- // because the optionMenu items are numbered starting at 1,
- // but our list in $gImageFormatData is indexed starting at 0.
- //
- if ($resItem > 1)
- {
- if ($resItem > ($numResolutionPresets + 1))
- {
- if ($resItem
- > ($numResolutionPresets + $numUserResolutionPresets + 1))
- {
- // It's one of the user-defined resolution nodes' presets
- string $resNodeName = $allResNodes[$resItem
- - $numResolutionPresets
- - $numUserResolutionPresets
- - 1];
- $resWidth = `getAttr ($resNodeName + ".resolutionX")`;
- $resHeight = `getAttr ($resNodeName + ".resolutionY")`;
- $resAspect = `getAttr ($resNodeName + ".deviceAspectRatio")`;
- }
- else
- {
- // It's one of the user-defined resolution presets
- $item = $gUserImageFormatData[$resItem
- - $numResolutionPresets - 2];
- int $numTokens = tokenize($item, $tokens);
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- }
- }
- else
- {
- // It's one of the built-in resolution presets
- $item = $gImageFormatData[$resItem - 2];
- int $numTokens = tokenize($item, $tokens);
- $resWidth = $tokens[1];
- $resHeight = $tokens[2];
- $resAspect = $tokens[3];
- }
-
- $pixAspect = $resAspect * ((float)$resHeight) / ((float)$resWidth);
-
- global float $deviceAspect;
- if ($deviceAspect != 0)
- $deviceAspect = (float)$resHeight / (float)$resWidth;
-
- setAttr "hardwareRenderGlobals.resolutionX" $resWidth;
- setAttr "hardwareRenderGlobals.resolutionY" $resHeight;
- setAttr "hardwareRenderGlobals.pixelAspectRatio" $pixAspect;
- }
-
- updateMayaHardwareResolution;
-
- setParent $oldParent;
- }
-
- global proc checkMayaHardwareAspectLockWidth()
- {
- string $nodeName = "hardwareRenderGlobals";
- float $deviceAspect;
-
- if (`checkBoxGrp -query -v1 aspectLockCheck`)
- {
- int $value = `getAttr ($nodeName + ".resolutionX")`;
-
- global float $deviceAspect;
- float $aspect = $deviceAspect;
-
- if ($aspect > 0.0)
- {
- int $rez = $aspect * $value;
- int $oldrez = `getAttr ($nodeName + ".resolutionY")`;
- if ($rez != $oldrez)
- {
- setAttr ($nodeName + ".resolutionY") $rez;
- }
- }
- else
- {
- checkMayaHardwareAspectLock;
- }
- }
- }
-
- global proc checkMayaHardwareAspectLockHeight()
- {
- string $nodeName = "hardwareRenderGlobals";
- float $deviceAspect;
-
- if (`checkBoxGrp -query -v1 aspectLockCheck`)
- {
- int $value = `getAttr ($nodeName + ".resolutionY")`;
-
- global float $deviceAspect;
- float $aspect = $deviceAspect;
-
- if ($aspect > 0.0)
- {
- int $rez = $value / $aspect;
- int $oldrez = `getAttr ($nodeName + ".resolutionX")`;
- if ($rez != $oldrez)
- {
- setAttr ($nodeName + ".resolutionX") $rez;
- }
- }
- else
- {
- checkMayaHardwareAspectLock;
- }
- }
- }
-
- global proc checkMayaHardwareAspectLock()
- {
- string $nodeName = "hardwareRenderGlobals";
-
- int $lockOn = `checkBoxGrp -query -v1 aspectLockCheck`;
- global float $deviceAspect;
-
- if ($lockOn)
- {
- float $h = `getAttr ($nodeName + ".resolutionY")`;
- float $w = `getAttr ($nodeName + ".resolutionX")`;
- float $aspect = $h / $w;
-
- $deviceAspect = $aspect;
- }
- else
- {
- $deviceAspect = 0;
- }
- }
-
- global proc changeMayaHardwareAspectLockWidth()
- //
- // Procedure Name:
- // changeAspectLockWidth
- //
- // Description:
- // This procedure is called when the user changes the
- // resolution width. It sets the internal representation
- // then looks at the ratio lock etc and changes any other
- // values that rely on it.
- //
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- int $requestedWidth = `intFieldGrp -q -v1 mayaHardwareResWidth`;
- int $isMayaEvalVersion = `about -ev`;
- if ($isMayaEvalVersion)
- {
- int $kPLEMaxX = 1024;
- int $kPLEMaxY = 768;
- if ($requestedWidth > $kPLEMaxX)
- {
- warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition");
- $requestedWidth = $kPLEMaxX;
- }
-
- if (`checkBoxGrp -query -v1 aspectLockCheck`)
- {
- global float $deviceAspect;
- float $aspect = $deviceAspect;
-
- if ($aspect > 0.0)
- {
- int $rez = $aspect * $requestedWidth;
- int $oldrez = `getAttr hardwareRenderGlobals.resolutionY`;
- if (($rez <= $kPLEMaxY) && ($rez != $oldrez))
- {
- setAttr hardwareRenderGlobals.resolutionY $rez;
- }
- else
- {
- intFieldGrp -e -v1 $kPLEMaxY mayaHardwareResHeight;
- changeMayaHardwareAspectLockHeight;
- return;
- }
- }
- }
- }
-
- if ($requestedWidth < 2)
- {
- warning "Width must be at least 2 pixels";
- $requestedWidth = 2;
- }
-
- // We need to test if anything changed to prevent an infinite loop
- // in the callbacks.
- if (`getAttr hardwareRenderGlobals.resolutionX` != $requestedWidth)
- setAttr hardwareRenderGlobals.resolutionX $requestedWidth;
- optionMenuGrp -edit -sl 1 resolutionMenu;
- checkMayaHardwareAspectLockWidth;
-
- // Update the values
- updateMayaHardwareResolution;
-
- adjustMayaHardwareDeviceAspect;
-
- setParent $oldParent;
- }
-
- global proc changeMayaHardwareAspectLockHeight()
- //
- // Procedure Name:
- // changeAspectLockHeight
- //
- // Description:
- // This procedure is called when the user changes the
- // resolution width. It sets the internal representation
- // then looks at the ratio lock etc and changes any other
- // values that rely on it.
- //
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- int $requestedHeight = `intFieldGrp -q -v1 mayaHardwareResHeight`;
- int $isMayaEvalVersion = `about -ev`;
- int $kPLEMaxX = 1024;
- int $kPLEMaxY = 768;
- if ($isMayaEvalVersion)
- {
- if ($requestedHeight > $kPLEMaxY)
- {
- warning("Image resolution is limited to "+$kPLEMaxX+"x"+$kPLEMaxY+" pixels for the Maya Personal Learning Edition");
- $requestedHeight = $kPLEMaxY;
- }
-
- if (`checkBoxGrp -query -v1 aspectLockCheck`)
- {
- global float $deviceAspect;
- float $aspect = $deviceAspect;
-
- if ($aspect > 0.0)
- {
- int $rez = $requestedHeight / $aspect;
- int $oldrez = `getAttr hardwareRenderGlobals.resolutionX`;
- if (($rez <= $kPLEMaxX) && ($rez != $oldrez))
- {
- setAttr hardwareRenderGlobals.resolutionX $rez;
- }
- else
- {
- intFieldGrp -e -v1 $kPLEMaxX mayaHardwareResWidth;
- changeMayaHardwareAspectLockWidth;
- return;
- }
- }
- }
- }
-
- if ($requestedHeight < 2)
- {
- warning "Height must be at least 2 pixels";
- $requestedHeight = 2;
- }
- // We need to test if anything changed to prevent an infinite loop
- // in the callbacks.
- if (`getAttr hardwareRenderGlobals.resolutionY` != $requestedHeight)
- setAttr hardwareRenderGlobals.resolutionY $requestedHeight;
- optionMenuGrp -edit -sl 1 resolutionMenu;
- checkMayaHardwareAspectLockHeight;
-
- // Update the values
- updateMayaHardwareResolution;
-
- adjustMayaHardwareDeviceAspect;
-
- setParent $oldParent;
- }
-
- global proc adjustMayaHardwareDeviceAspect()
- {
- string $oldParent = `setParent -q`;
- setParentToCommonTab();
-
- string $nodeName = "hardwareRenderGlobals";
- string $widthAttr = $nodeName + ".resolutionX";
- string $heightAttr = $nodeName + ".resolutionY";
-
- float $pixelAspectRatio = `getAttr hardwareRenderGlobals.pixelAspectRatio`;
-
- float $aspect = (float)`getAttr $widthAttr` / (float)`getAttr $heightAttr`;
- $aspect = $pixelAspectRatio * $aspect;
- floatFieldGrp -edit -v1 $aspect resRatio;
-
- setParent $oldParent;
- }
-